home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / ibus / object.py < prev    next >
Text File  |  2009-11-05  |  2KB  |  58 lines

  1. # vim:set et sts=4 sw=4:
  2. #
  3. # ibus - The Input Bus
  4. #
  5. # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this program; if not, write to the
  19. # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20. # Boston, MA  02111-1307  USA
  21.  
  22. __all__ = (
  23.         "Object",
  24.     )
  25.  
  26. import gobject
  27.  
  28. class Object(gobject.GObject):
  29.     __gtype_name__ = "PYIBusObject"
  30.     __gsignals__ = {
  31.         'destroy' : (
  32.             gobject.SIGNAL_RUN_LAST,
  33.             gobject.TYPE_NONE,
  34.             ())
  35.     }
  36.  
  37.     def __init__(self):
  38.         super(Object, self).__init__()
  39.         self.__destroyed = False
  40.         self.__handlers = []
  41.  
  42.     def destroy(self):
  43.         if not self.__destroyed:
  44.             self.emit("destroy")
  45.             self.__destroyed = True
  46.  
  47.     def do_destroy(self):
  48.         self.__disconnect_all()
  49.  
  50.     def connect(self, signal_name, handler, *args):
  51.         id = super(Object, self).connect(signal_name, handler, *args)
  52.         self.__handlers.append(id)
  53.  
  54.     def __disconnect_all(self):
  55.         map(self.disconnect, self.__handlers)
  56.         self.__handlers = []
  57.  
  58.